package 链表;

import java.util.List;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/10/9 9:43
 */
public class Node {
    int val;
    Node next;
    Node random;

    public Node(int val) {
        this.val = val;
        this.next = null;
        this.random = null;
    }

    public static Node init(List<Integer> list) {
        Node head = new Node(0);
        Node cur = head;
        for (Integer i : list) {
            cur.next = new Node(i);
            cur = cur.next;
        }
        return head.next;
    }

    @Override
    public String toString() {
        return "Node{" +
                "val=" + val +
                ", next=" + next +
                ", random=" + random +
                '}';
    }
}
